#ifndef CHATDIALOG_H
#define CHATDIALOG_H

#include <QDialog>
#include <QScrollBar>
#include"../global.h"
#include"../widget/chatuserwid.h"

namespace Ui {
class ChatDialog;
}

class ChatDialog : public QDialog
{
    Q_OBJECT

public:
    explicit ChatDialog(QWidget *parent = nullptr);
    ~ChatDialog();

    void addChatFrame(const QString &sender, const QString &text, const UserType &type, const NewsType &nt, const QDateTime &time, bool b);
private:
    void loadMoreUser();
    void loadChatRecord();

protected:
    void keyPressEvent(QKeyEvent *event) override;

public slots:
    void slot_contacts_switch_user(const QString& name);
    void slot_add_group(const QString& name, const int num, const QString& uuid);
private slots:
    void slot_load_user(int v);//加载用户
    void slot_load_chat_record(int v);//加载聊天消息
    void slot_add_friend(const QString& name);
    void slot_switch_user(const QString& name);
    void on_sendBtn_clicked();
    void slot_add_text_msg(const QString& sender, const QString& msg);
    void slot_add_offline_text_msg(const QString& sender, const QString& msg, const QDateTime&);
    void on_pushButton_3_clicked();

signals:
    void sig_switch_user(const QString&);

private:
    Ui::ChatDialog *ui;
    bool clickedOnce{true};
    QString _receiverUser{""};
    QMap<QString, ChatUserWid*> _chatRoomMap;
    int _userNum{1};
};

#endif // CHATDIALOG_H
